package com.yitao.client.constant;

import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 官网操作日志记录
 *
 * @Date: 2019/10/9 17:25
 * @Author: Kien
 */
public class PcShopLogEnums {

    /**
     * pc操作菜单枚举
     */
    public enum MENU_TYPE{
        /**
         * 00开头登录注册
         */
        LOGIN("0001", "登录"),
        LOGIN_OUT("0002", "退出登录"),
        REGISTER("0003", "注册"),

        /**
         * 01开头基础分类操作
         */
        MEIRONGCAIZHUANG("2", "美容彩妆"),
        GERENXIHU("3", "个人洗护"),
        SHISHANGNVXING("4", "时尚女性"),
        FENGSHANGNANXING("5", "风尚男性"),
        JIAJUYONGPIN("9", "家居用品"),

        /**
         * 02开头商品操作
         */
        PRODUCT_DETAIL("0201", "商品详情"),
        ADD_SHOPPING_CART("0202", "加入购物车"),
        PURCHASE("0203", "购买"),
        PRODUCT_SEARCH("0204", "商品搜索"),

        /**
         * 03其他
         */
        CONTACT_BUSINESS("0301", "联系商家"),
        PC_INDEX("0302", "打开首页"),
        MERCHANT_PUBLISHING("0303", "商家发布"),
        QITA("0000", "其他"),
        ;

        private String code;
        private String msg;
        private static List<Map<String, String>> list = new ArrayList<>();
        private static Map<String, String> map = new HashMap<>();

        static {
            for(PcShopLogEnums.MENU_TYPE menu_type: PcShopLogEnums.MENU_TYPE.values()) {
                Map<String, String> tempMap = new HashMap<>();
                tempMap.put("code", menu_type.getCode());
                tempMap.put("msg", menu_type.getMsg());
                list.add(tempMap);
                map.put(menu_type.getCode(), menu_type.getMsg());
            }
        }

        MENU_TYPE(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public String getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }

        /**
         * 获取枚举列表
         * @return
         */
        public static List<Map<String, String>> getEnumList(){
            return list;
        }

        /**
         * 根据code获取对应的msg
         * @param code
         * @return
         */
        public static String getMsgByCode(String code) {
            if(StringUtils.isBlank(code)) {
                return null;
            }
            return map.get(code);
        }


    }
}
